package com.nongtai.mapper;


import java.util.List;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.nongtai.pojo.entity.GoodsCategory;
import com.nongtai.pojo.entity.GoodsCategoryExample;
import com.nongtai.pojo.vo.SubCategoryVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;


public interface GoodsCategoryMapper extends BaseMapper<GoodsCategory> {
    long countByExample(GoodsCategoryExample example);

    int deleteByExample(GoodsCategoryExample example);

    int deleteByPrimaryKey(Long id);

    int insert(GoodsCategory record);

    int insertSelective(GoodsCategory record);

    List<GoodsCategory> selectByExample(GoodsCategoryExample example);

    GoodsCategory selectByPrimaryKey(Long id);

    int updateByExampleSelective(@Param("record") GoodsCategory record, @Param("example") GoodsCategoryExample example);

    int updateByExample(@Param("record") GoodsCategory record, @Param("example") GoodsCategoryExample example);

    int updateByPrimaryKeySelective(GoodsCategory record);

    int updateByPrimaryKey(GoodsCategory record);

    /**
     * 查询商品分类中的一级(顶层)分类 即parent_id为null的
     * @return
     */
    @Select("select id,name,picture from goods_category where parent_id is null")
    List<GoodsCategory> selectGoodsFirstCategory();

    /**
     * 根据id查询二级分类，只包含二级分类的信息和它父分类的名字 不包含该分类的商品信息
     */
    SubCategoryVo selectSubCategoryById(Long id);
}